package triangle.freshmanemail;

import java.io.File;
import java.util.ArrayList;

import triangle.utils.SaveLoad;

public class EmailCSVSaver {

	private static final String SUFFIX = ".appended.csv";
	public static void saveFile(String filename, ArrayList<EmailStoreStructure> data)
	{
		filename = filename + SUFFIX;
		File f = new File(filename);
		if (f.exists())
		{
			f.delete(); // delete if file exists
		}
		String saveContent = "LASTNAME,FIRSTNAME,MIDDLENAME,EMAIL+\n";
		for (EmailStoreStructure datum : data)
		{
			saveContent += datum.toString() + "\n";
		}
		SaveLoad.saveFile(filename, saveContent);
	}
}
